using SeataNet.Core.AT.UndoLog;

namespace SeataNet.Core.Database
{
    /// <summary>
    /// SQL识别器接口
    /// </summary>
    public interface ISqlRecognizer
    {
        /// <summary>
        /// 获取SQL类型
        /// </summary>
        SqlType GetSqlType();

        /// <summary>
        /// 获取表名
        /// </summary>
        string GetTableName();

        /// <summary>
        /// 识别SQL并返回结果
        /// </summary>
        SqlRecognizeResult Recognize();
    }

    /// <summary>
    /// SQL识别结果
    /// </summary>
    public class SqlRecognizeResult
    {
        /// <summary>
        /// SQL类型
        /// </summary>
        public SqlType SqlType { get; set; }

        /// <summary>
        /// 表名
        /// </summary>
        public string TableName { get; set; }

        /// <summary>
        /// 原始SQL
        /// </summary>
        public string OriginalSql { get; set; }

        /// <summary>
        /// INSERT语句的列名（仅INSERT有效）
        /// </summary>
        public List<string> InsertColumns { get; set; } = new List<string>();

        /// <summary>
        /// UPDATE语句的列名（仅UPDATE有效）
        /// </summary>
        public List<string> UpdateColumns { get; set; } = new List<string>();

        /// <summary>
        /// WHERE条件（UPDATE/DELETE有效）
        /// </summary>
        public string WhereCondition { get; set; }

        /// <summary>
        /// 是否包含主键条件
        /// </summary>
        public bool HasPrimaryKeyCondition { get; set; }
    }
}
